<?php include 'application/views/header.php' ?>
<h4 class="page-title">Khách hàng</h4>
<div class="toolbar-set">
    <input type="button" class="btnAdd" value="Thêm khách hàng" />
</div>
<table width="100%" class="list list-customer">
    <tr>
        <th>STT</th>
        <th>Tên khách hàng</th>
        <th>Địa chỉ khách hàng</th>
        <th>Điện thoại</th>
        <th>Nhóm</th>
        <th>Hiển thị</th>
        <th>Thao tác</th>
    </tr>
    <?php $index = 1 ?>
    <?php foreach($Customers as $customer): ?>
    <tr>
       <td><?php echo $index++ ?></td>
       <td><?php echo $customer['CustomerName'] ?></td>
       <td><?php echo $customer['CustomerAddress'] ?></td>
       <td><?php echo $customer['CustomerPhone'] ?></td>
       <td><?php echo $customer['CategoryName'] ?></td>
       <td><?php echo ($customer['Visible'] ? 'Hiện' : 'Ẩn')?></td>
       <td>
            <a href="<?php echo base_url() ?>customer/edit/<?php echo $customer['CustomerId'] ?>.html">
                <div class="actEdit">Edit</div>
            </a>
            <a href="#">
                <div class="actDelete" customerId="<?php echo $customer['CustomerId'] ?>">Edit</div>
            </a>
       </td>
    </tr>
    <?php endforeach; ?>
</table>
<div class="toolbar-set">
    <input type="button" class="btnAdd" value="Thêm khách hàng" />
</div>

<?php include 'application/views/footer.php' ?>

<script>
$('.btnAdd').click(function(){
    window.location.href = '<?php echo base_url() ?>customer/add.html'; 
});
$('.actDelete').click(function(){
    var customerId = $(this).attr('customerId');
    if(confirm("Bạn có muốn xóa không?")){
        window.location.href = '<?php echo base_url() ?>customer/delete/'+customerId;
    }
    return false;
});
</script>